from django.core import serializers

def serialize_dishes(dishes, user):
    # if (user.is_authenticated()):
        # for d in dishes:
            # d.set_user_dependent_flags(user)

    return serializers.serialize('json', dishes, extras=('get_thumbnail_url', 'medium_img_url', 'is_liked_by_curr_user', 'is_disliked_by_curr_user', 'is_okd_by_curr_user', 'get_place_name'), relations=('dishimage_set',), use_natural_keys=True)

def serialize_ranks(ranks):
    return serializers.serialize('json', ranks, use_natural_keys=True)

# def serialize_reviews(reviews, user):
    # return serializers.serialize('json', reviews, extras=('get_user_profile_icon_url', 'get_username'), use_natural_keys=True) # extras must be list!!! i.e. add a comma after first string

def serialize_dish_photos_urls(photos):
    return serializers.serialize('json', photos, extras=('get_thumbnail_url',), use_natural_keys=True)